var $JsApi_Share = {
	init: function(obj) {
		if(!obj){
			return;
		}
		if(obj.title)
			$JsApi_Share.title = obj.title;
		if(obj.desc)
			$JsApi_Share.desc = obj.desc;
		if(obj.link)
			$JsApi_Share.link = obj.link;
		if(obj.imgUrl)
			$JsApi_Share.imgUrl = obj.imgUrl;
//		$JsApi_Share.type = obj.type;
//		$JsApi_Share.dataUrl = obj.dataUrl;
//		$JsApi_Share.success = obj.success;
//		$JsApi_Share.cancel = obj.cancel;
	},
	title: '微信新一波大奖来袭',
	desc: "端午摇一摇粽大奖，送流量，送话费",
	link: 'http://dwz.cn/OMQVa',
	imgUrl: 'http://www.gofull.com.cn/game/dwGame/images/shareimg.jpg',
	type: null,
	dataUrl: null,
	success: shareCallback,
	cancel: null
};
function shareCallback(){
	$.ajax( {
		dataType : 'json',
		url :"http://www.gofull.com.cn/dwGameWxShare.do",
		data : {},
		type : 'POST',
		beforeSend : function() {
		},
		success : function(data) {
			$(".reveal-modal-bg").fadeOut(1000);
		},
		error : function() {
		}
	});
}
$(function() {
	wx.ready(function() {
		wx.onMenuShareTimeline({
		    title: $JsApi_Share.title,
		    link: $JsApi_Share.link,
		    imgUrl: $JsApi_Share.imgUrl,
		    success: $JsApi_Share.success,
		    cancel: $JsApi_Share.cancel
		});
		wx.onMenuShareAppMessage({
		    title: $JsApi_Share.title,
		    desc: $JsApi_Share.desc,
		    link: $JsApi_Share.link,
		    imgUrl: $JsApi_Share.imgUrl,
		    type: $JsApi_Share.type,
		    dataUrl: $JsApi_Share.dataUrl,
		    success: $JsApi_Share.success,
		    cancel: $JsApi_Share.cancel
		});
		wx.onMenuShareQQ({
		    title: $JsApi_Share.title,
		    desc: $JsApi_Share.desc,
		    link: $JsApi_Share.link,
		    imgUrl: $JsApi_Share.imgUrl,
		    success: $JsApi_Share.success,
		    cancel: $JsApi_Share.cancel
		});
		wx.onMenuShareWeibo({
		    title: $JsApi_Share.title,
		    desc: $JsApi_Share.desc,
		    link: $JsApi_Share.link,
		    imgUrl: $JsApi_Share.imgUrl,
		    success: $JsApi_Share.success,
		    cancel: $JsApi_Share.cancel
		});
		wx.hideMenuItems({
	      menuList: [
	        'menuItem:copyUrl', 
	        'menuItem:originPage', 
	        'menuItem:openWithQQBrowser',
	        'menuItem:openWithSafari'
	      ],
	      success: function (res) {
	      },
	      fail: function (res) {
	      }
		});
	});
	
	wx.error(function(res){
	});

	var param = {};
	param["paramMap.url"] = window.location.href;
	$.ajax( {
		dataType : 'json',
		url :"http://www.gofull.com.cn/wchatJsSDKConfig.do",
		data : param,
		type : 'POST',
		beforeSend : function() {
		},
		success : function(data) {
			var wxConfigInfo = data.wxConfigMap;
			// 通过config接口注入权限验证配置
			wx.config( {
				debug : false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
				appId : wxConfigInfo.appId, // 必填，公众号的唯一标识
				timestamp : wxConfigInfo.timestamp, // 必填，生成签名的时间戳
				nonceStr : wxConfigInfo.nonceStr, // 必填，生成签名的随机串
				signature : wxConfigInfo.signature,// 必填，签名，见附录1
				jsApiList : [
						// 必填，需要使用的JS接口列表，所有JS接口列表见附录2
						'checkJsApi', 'getNetworkType',
						'onMenuShareAppMessage', 'onMenuShareTimeline',
						'hideOptionMenu', 'closeWindow' ]
			});
		},
		error : function() {
		}
	});
});